<template>
    <div>
        <el-sub-menu v-if="item.type == '1'" :index="item.id + ''">
            <template #title>
                <el-icon>
                    <component :is="item.icon"></component>
                </el-icon>
                <span>{{ item.name }}</span>
            </template>
            <MenuItem v-for="child in item.children" :key="child.index" :item="child" />
        </el-sub-menu>
        <el-menu-item v-if="item.type == '2'" :index="item.perm" @click="changeMenu(item.perm)">
            <template #title>
                <el-icon>
                    <component :is="item.icon"></component>
                </el-icon>
                <span>{{ item.name }}</span>
            </template>
        </el-menu-item>
    </div>
</template>

<script setup>
const props = defineProps({
    item: Object,
});

const changeMenu = (path) => {
    localStorage.setItem("currentMenu",path)
}
</script>
